<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>协作申请表详情-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.form-main .form-sub-title{ background-color: #f6f6f6;}
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">协作申请 > 协作申请表详情</div>
	</div>
	<div id="content">
		<form action="__APP__/Index/assist_apply_edit" method="post" enctype="multipart/form-data">
			<input type="hidden" name="action" value="doedit">
			<input type="hidden" name="id" value="{$result['id']}">
			<div class="form-main">
				<div class="form-title">协作申请表详情</div>
				<div class="form-item">
					<div class="input-label">选择项目</div>
					<div class="input-item">
						[{$project['project_num']}]{$project['project_name']}
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">协作工作性质</div>
					<div class="input-item">
						<span class="mr10 checkbox-item">
							{$result['work_nature']}
						</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">需求部门</div>
					<div class="input-item">
						<span class="mr10 checkbox-item">
							{$result['demand_depart']}
						</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">申请人(部门)</div>
					<div class="input-item">
						{$user['username']}({$user['position_descr']})
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">联系电话</div>
					<div class="input-item">
						{$user['mobilephone']}
					</div>
				</div>
				<div class="form-sub-title">申请需求内容</div>
				<div class="editor_cont">
					<div class="form-item">
						<div class="input-label">主要需求</div>
						<div class="input-item">
							{$result['main_demand']}
						</div>
					</div>
				</div>
				<if condition="$detail[0]['file_name'] neq NULL">
				<div class="form-sub-title">提供介绍材料索引</div>
					<foreach name="detail" item="vo">
					<div class="editor_cont">
					<div class="form-item">
						<div class="input-label"><if condition="$key eq 0">上传资料</if></div>
						<div class="input-item">
							<div class="input-group w200 left mr10">
								{$vo['file_name']}<a href="{$vo['file_url']}" class="ml5" data-toggle="tooltip" data-placement="right" title="下载"><i class="glyphicon glyphicon-download-alt"></i></a>
							</div>
						</div>
					</div>
					</div>
					</foreach>
				</if>
				<if condition="$result['confirm_message'] neq NULL">
				<div class="form-sub-title">确认详情</div>
				<div class="form-item">
					<div class="input-label">确认意见</div>
					<div class="input-item">
						<div class="input-group w200 left mr10">
							{$result['confirm_message']}
						</div>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">确认建议</div>
					<div class="input-item">
						<div class="input-group w200 left mr10">
							{$result['confirm_proposal']}
						</div>
					</div>
				</div>
				<div class="editor_cont">
				<div class="form-item">
					<div class="input-label">确认评分</div>
					<div class="input-item">
						<div class="input-group w200 left mr10">
							{$result['confirm_evaluate']}
						</div>
					</div>
				</div>
				</div>
				</if>
				<if condition="$result['status'] neq -1">
					<div class="form-sub-title">审核流程</div>
					<foreach name="audit_user" item="vo">
						<div class="form-item clearfix">
							<div class="input-label">{$vo['audit_name']}</div>
							<div class="input-item">
								<if condition="$vo['audit_date'] neq NULL">
									{$vo['audit_user']}({$vo['audit_date']|substr=0,10})<if condition="$vo['audit_comments'] neq NULL">批复:{$vo['audit_comments']}</if><if condition="$vo['dh_message'] neq NULL"><br/><span>打回至"{$vo['arrive_name']}"({$vo['dh_date']|substr=0,10})原因:{$vo['dh_message']}</span></if><if condition="$vo['arrive_info'] neq NULL"><br/><span>"{$vo['arrive_name']}"({$vo['arrive_date']|substr=0,10})回复:{$vo['arrive_info']}</span></if>
								<else/>
									<span class='red'>[未审核]{$vo['audit_user']}</span><if condition="$vo['dh_message'] neq NULL"><br/><span class='red'>打回至"{$vo['arrive_name']}"({$vo['dh_date']|substr=0,10})原因:{$vo['dh_message']}</span></if><if condition="$vo['arrive_info'] neq NULL"><br/><span class='red'>"{$vo['arrive_name']}"({$vo['arrive_date']|substr=0,10})回复:{$vo['arrive_info']}</span></if>
								</if>
							</div>
						</div>
					</foreach>
					<div class="form-item clearfix">
						<div class="item-float">
							<div class="input-label">确认人</div>
							<div class="input-item">
								<if condition="$result['confirm_date'] neq NULL">
									{$user['username']}({$result['confirm_date']|substr=0,10})
								<else/>
									<span class='red'>[未确认]{$user['username']}</span>
								</if>
							</div>
						</div>
					</div>
				</if>
				<!--<if condition="$result['dh_uid'] neq NULL">
					<div class="form-item clearfix">
						<div class="item-float">
							<div class="input-label"><span class="red">打回原因</span></div>
							<div class="input-item">
								<span class="red">{$result['dh_user']}({$result['dh_date']|substr=0,10}):{$result['dh_message']}</span>
							</div>
						</div>
					</div>
				</if>
				<if condition="$result['submit_info'] neq NULL">
					<div class="form-item clearfix">
						<div class="item-float">
							<div class="input-label"><span class="red">重新提交理由</span></div>
							<div class="input-item">
								<span class="red">{$result['submit_user']}:{$result['submit_info']}</span>
							</div>
						</div>
					</div>
				</if>-->
			</div>
			<div class="form-btn-item">
				<if condition="($state eq 1 or $state eq -10) and ($shenhe eq 1)">
					<button status="{$result['status']}" mid="{$result['id']}" uuid="{$login_id}" class="btn btn-audit2 mr5" type="button">审核</button>
					<button status="-1" mid="{$result['id']}" uuid="{$login_id}" class="btn btn-back mr5" type="button">打回</button>
				<elseif condition="($state eq 2 or $state eq -10 or $state eq 1) and ($qishen eq 1) and ($result['status'] neq 4)"/>
					<button status="{$result['status']}" mid="{$result['id']}" class="btn btn-remove mr5" type="button">弃审</button>
				<elseif condition="$result['status'] eq 3 and $login_id eq $result['add_uid']"/>
					<button status="{$result['status']}" mid="{$result['id']}" class="btn true mr5" type="button">完成确认</button>
				</if><button class="btn btn-default goback" type="button">返回</button>
			</div>
		</form>
	</div>
</div>
<!--弹框-->
<div class="modal fade" id="edit-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4></h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="74"><strong><span class="asterisk">*</span>审核</strong></td>
						<td>
							<textarea name="text_hid" class="form-control required-text" style="width:100%; height:150px" autocomplete="off"></textarea>
							<input type="hidden" name="audit1_message">
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--打回弹框-->
<div class="modal fade" id="back-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4></h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="95"><strong><span class="asterisk">*</span>打回阶段</strong></td>
						<td>
							<select name="arrive_status" class="form-control required-selted" autocomplete="off">
								<option value="-10" selected>请选择</option>
								<foreach name="audit_list" item="vo">
									<option value="{$vo['audit_sort']}">{$vo['audit_name']}</option>
								</foreach>
							</select>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right" width="95"><strong><span class="asterisk">*</span>是否重走流程</strong></td>
						<td class="radios">
							<label class="radio-inline"><input type="radio" name="flow_status" value="1" autocomplete="off">是</label>
							<label class="radio-inline"><input type="radio" name="flow_status" value="-1" autocomplete="off">否</label>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right" width="95"><strong><span class="asterisk">*</span>打回原因</strong></td>
						<td>
							<textarea name="dh_message" class="form-control required-text1" style="width:100%; height:150px" autocomplete="off"></textarea>
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm2">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--弹出框-->
<div class="modal fade" id="customeModal">
	<div class="modal-dialog w800">
		<div class="modal-content">
			<div class="modal-header">
				<h4>完成确认</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<table class="table table-bordered">
					<tr>
						<td class="side_td" width="12%"><span class="asterisk">*</span>确认内容</td>
						<td width="88%"><textarea name="confirm" class="form-control w600 h150" autocomplete="off"></textarea><input name="confirm_hid" type="hidden"><span class="error-item">必填项</span></td>
					</tr>
					<tr>
						<td class="side_td" width="12%">改进建议</td>
						<td width="88%"><textarea name="confirm_proposal" class="form-control w600 h150" autocomplete="off"></textarea><input name="confirm_proposal_hid" type="hidden"></td>
					</tr>
					<tr>
						<td class="side_td" width="12%"><span class="asterisk">*</span>总体评价</td>
						<td>
							<label class="radio-inline"><input type="radio" name="confirm_evaluate" value="优" autocomplete="off">优</label>
							<label class="radio-inline"><input type="radio" name="confirm_evaluate" value="良" autocomplete="off">良</label>
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-affirm">确认</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	$("[name='text_hid']").each(function(){
		var textss = $(this).text(),
			reg2 = new RegExp("<br/>", "g"),
			str = textss.replace(reg2, "\n");
		$(this).html(str);
	})
	//文本域暂存
	$("[name='text_hid']").blur(function(){
		var val = $(this).val();
			reg = new RegExp("\n", "g"),
    		str = val.replace(reg, "<br/>");
		$("[name='audit1_message']").val(str);
	})
	//审核弹框
	$(".btn-audit2").on("click",function(){
		var modal = $("#edit-modal"),
			mid = $(this).attr("mid"),
			uuid = $(this).attr("uuid"),
			status = parseInt($(this).attr('status'))+1;
		modal.find(".modal-header h4").text("审核");
		modal.find(".file-name").prop("readonly",true);
		modal.find(".file-delete").hide();
		modal.find(".btn-affirm").attr({"mid":mid});
		modal.find(".btn-affirm").attr({"uuid":uuid});
		modal.find(".btn-affirm").attr({"status":status});
		modal.modal();
		modal.find("textarea").val('');
	});
	//取消
	$("#edit-modal").on('hidden.bs.modal',function(){
		$(this).find(".error-item").hide();
	});
	//审核
	$("#edit-modal").find(".btn-affirm").on("click",function(){
		var tag = false;
		$(".required-text").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = true;
			}
		});
		
		if(tag){
			return false;
		}else{
			var mid = $(this).attr("mid"),
				uuid = $(this).attr("uuid"),
				status = $(this).attr("status"),
				state = 1,
				audit1_message = $("[name='audit1_message']").val(),
				modal = $("#edit-modal");
			modal.hide();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"mid":mid,"audit1_message":audit1_message,"uuid":uuid,"status":status,"state":state},
				url:"__APP__/Index/assist_apply_audit_ajax",
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	$(document).on("focus",".required-text",function(){
		$(this).nextAll(".error-item").hide();
	});
	//打回
	$(".btn-back").on("click",function(){
		var modal = $("#back-modal"),
			mid = $(this).attr("mid"),
			uuid = $(this).attr("uuid"),
			status = $(this).attr("status");
		modal.find(".modal-header h4").text("打回");
		modal.find(".file-name").prop("readonly",true);
		modal.find(".file-delete").hide();
		modal.find(".btn-affirm2").attr({"mid":mid});
		modal.find(".btn-affirm2").attr({"uuid":uuid});
		modal.find(".btn-affirm2").attr({"status":status});
		modal.modal();
		modal.find("textarea").val('');
		modal.find("[name='arrive_status']").val('-10').select2();
		modal.find("[name='flow_status']").attr('checked',false);
	});
	//取消
	$("#back-modal").on('hidden.bs.modal',function(){
		$(this).find(".error-item").hide();
	});
	$("#back-modal").find(".btn-affirm2").on("click",function(){
		var tag = false;
		$(".required-text1").each(function(){
			var val = $(this).val();
			if(val=="" || /^\s+$/.test(val)){
				$(this).next(".error-item").show();
				tag = true;
			}
		});
		$("[name='arrive_status']").each(function(){
			var val = $(this).val();
			if(val==-10){
				$(this).nextAll(".error-item").show();
				tag = true;
			}
		})
		if($("#back-modal").find("input:radio:checked").length==0){
			$("#back-modal .radios").find(".error-item").show();
			tag = true;
		}
		if(tag){
			return false;
		}else{
			var modal = $("#back-modal"),
				mid = $(this).attr("mid"),
				uuid = $(this).attr("uuid"),
				status = $(this).attr("status"),
				dh_status = "{$result['status']}",
				dh_message = $("[name='dh_message']").val(),
				arrive_status = $("[name='arrive_status']").val(),
				flow_status = modal.find('input:radio:checked').val();
				
			modal.hide();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"mid":mid,"dh_message":dh_message,"uuid":uuid,"status":status,"flow_status":flow_status,"arrive_status":arrive_status,"dh_status":dh_status},
				url:"__APP__/Index/assist_apply_audit_ajax",
				success:function(data){
					success_pop(data['status'],data['msg']);
				}
			});
		}
	});
	//取消验证
	$(document).on("focus",".required-text1",function(){
		$(this).nextAll(".error-item").hide();
	});
	$("[name='arrive_status']").change(function(){
		$(this).nextAll(".error-item").hide();
	})
	$("#back-modal .radios label").click(function(){
		$("#back-modal .radios .error-item").hide();
	})
	//弃审
	$('.btn-remove').on("click",function(){
		var status = $(this).attr('status'),
			state = 2,
			mid = $(this).attr("mid");
		$.ajax({
			cache:true,
			type:"POST",
			dataType:"json",
			url:"__APP__/Index/assist_apply_audit_ajax",
			data:{"mid":mid,"status":status,"state":state},
			success:function(data){
				success_pop(data['status'],data['msg']);
			}
		});
	});
	//文本域暂存
	$("textarea").blur(function(){
		var val = $(this).val();
			reg = new RegExp("\n", "g"),
    		str = val.replace(reg, "<br/>");
		$(this).next("input").val(str);
	})
	$('.true').click(function(){
		var mid = $(this).attr("mid"),
			status = parseInt($(this).attr('status'))+1;
		$('#customeModal').find('.modal-body').end().modal('show');
		$('#customeModal').find(".btn-affirm").attr({"mid":mid});
		$('#customeModal').find(".btn-affirm").attr({"status":status});
		$('#customeModal').find("textarea").val('');
		$('#customeModal').find("[name='confirm_evaluate']").attr('checked',false);
	})
	
	//提交
	$('.btn-affirm').click(function(){
		var tag = true;
		$("[name='confirm']").each(function(){
			var val = $(this).val();
			if(val==''){
				$(this).parent().find('.error-item').show();
				tag = false;
			}
		})
		if($("td").find("input:radio:checked").length==0){
			$('.radio-inline').parent().find(".error-item").show();
			tag = false;
		}
		if(tag){
			var mid = $(this).attr("mid"),
				status = $(this).attr("status"),
				confirm = $("[name='confirm_hid']").val(),
				confirm_proposal = $("[name='confirm_proposal_hid']").val(),
				confirm_evaluate = $('input:radio:checked').val(),
				modal = $("#customeModal");
			modal.hide();
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:{"mid":mid,"status":status,"confirm_message":confirm,"confirm_proposal":confirm_proposal,"confirm_evaluate":confirm_evaluate},
				url:"__APP__/Index/assist_apply_audit_ajax",
				success:function(data){
					success_pop(data.status);
				}
			});
		}
	})
	$("[name='confirm'],.radio-inline").click(function(){
		$(this).parent().find(".error-item").hide();
	})
});
</script>
</body>
</html>